<!DOCTYPE html>
<html>

<head>
    <title>jwtTest</title>
    <script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script>
</head>

<body>
    <div id="but1">获取token</div>
    <div id="but2">验证token</div>
    <script type="text/javascript">
    	var  token;
    $('#but1').click(function(event) {
        $.ajax({
            url: "http://172.16.21.227:3000/",
            method: "get",
            success: function(data) {
                console.log(data)
                token=data.token

            },
            error: function(err) {
                console.log(err)
            }
        })
    });
    $('#but2').click(function(event) {
        $.ajax({
            url: "http://172.16.21.227:3000/xxoo",
            method: "get",
            headers: {'Authorization':"Bearer "+ token},
            success: function(data) {
                console.log(data)

            },
            error: function(err) {
                console.log(err)
            }
        })
    });
    </script>
</body>

</html>